//
//  DDRightViewController.m
//  ialone
//
//  Created by lanou on 16/1/11.
//  Copyright © 2016年 JasperSong. All rights reserved.
//

#import "DDRightViewController.h"
#import "DDLoginView.h"
#import "DDNoLoginView.h"
#import "DDManager.h"
#import "DDSettingsViewController.h"

#import "DDSoundModel.h"
#import "DDCollectViewController.h"
@interface DDRightViewController ()<UITextFieldDelegate>

@end

@implementation DDRightViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   
    [self addSubviews];
   
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    UILabel *label = (UILabel *)[self.view viewWithTag:1000];
    label.text = [[DDManager sharedHandle] username];
}

- (void)addSubviews
{
    // 未登录状态
    DDNoLoginView *noLoginView = [[DDNoLoginView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    noLoginView.backgroundColor = [UIColor colorWithRed:50/255.0 green:50/255.0 blue:48/255.0 alpha:1];
    //    // 返回
    [noLoginView.returnButton setImage:[UIImage imageNamed:@"back"] forState:(UIControlStateNormal)];
    [noLoginView.returnButton setImage:[UIImage imageNamed:@"back"] forState:(UIControlStateHighlighted)];
    [noLoginView.returnButton addTarget:self  action:@selector(back:) forControlEvents:(UIControlEventTouchUpInside)];
    // 设置
    [noLoginView.setButton setImage:[UIImage imageNamed:@"Settings"] forState:(UIControlStateNormal)];
    [noLoginView.setButton setImage:[UIImage imageNamed:@"Settings"] forState:(UIControlStateHighlighted)];
    [noLoginView.setButton addTarget:self action:@selector(settingsButton:) forControlEvents:(UIControlEventTouchUpInside)];
    
    // 名字
    noLoginView.nameLable.text = [[DDManager sharedHandle] username];
    
    // 收藏
    [noLoginView.collectButton setTitle:@"收     藏" forState:(UIControlStateNormal)];
    [noLoginView.collectButton addTarget:self action:@selector(collectButton:) forControlEvents:UIControlEventTouchUpInside];
    noLoginView.collectButton.titleLabel.font = [UIFont systemFontOfSize:32];
    
    // 单项空间
    noLoginView.owspaceLable.text = @"單向空間";
    noLoginView.owspaceLable.textColor = [UIColor whiteColor];
    noLoginView.owspaceLable.font = [UIFont systemFontOfSize:20];
    noLoginView.owspaceLable.textAlignment = NSTextAlignmentCenter;
    // 版本
    noLoginView.vertionLable.text = @"vertion1.0.0";
    noLoginView.vertionLable.font = [UIFont systemFontOfSize:14];
    noLoginView.vertionLable.textAlignment = NSTextAlignmentCenter;
    
    [self.view addSubview:noLoginView];
    
}
- (void)collectButton:(UIButton *)button
{
    
    DDCollectViewController *collect = [[DDCollectViewController alloc]init];
    
    [self.navigationController pushViewController:collect animated:YES];
    
}
- (void)back:(UIButton *)button{
    
    [UIView animateWithDuration:0.3 animations:^{
        for (int i = 0; i < 2; i ++){
            UIButton *button = (UIButton *)[self.view viewWithTag:7890 + i];
            button.transform = CGAffineTransformScale(button.transform, 0.1, 0.1);
        }
        
        
    } completion:^(BOOL finished) {
        for (int i = 0; i < 2; i ++){
            UIButton *button = (UIButton *)[self.view viewWithTag:7890 + i];
            button.hidden = YES;
        }
        [UIView animateWithDuration:1 animations:^{
            self.view.frame = CGRectMake(kScreenWidth, 0, kScreenWidth, kScreenHeight);
        }];
       
        UIButton *button = (UIButton *)[self.view viewWithTag:1250];
        [UIView animateWithDuration:1.2   animations:^{
            button.frame = CGRectMake(kScreenWidth, kScreenHeight/2+30, kScreenWidth/3, 50);
        }];
        
    }];
}
- (void)settingsButton:(UIButton *)button
{
    DDSettingsViewController *setting = [[DDSettingsViewController alloc]init];
    
    [self.navigationController pushViewController:setting animated:YES];
}





// 键盘回弹
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    
    return YES;
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
